package com.axc.gallery2.edit;

import java.io.File;
import java.io.FileOutputStream;
import java.text.SimpleDateFormat;

import android.content.Context;
import android.graphics.Bitmap;
import android.os.Environment;
import android.widget.Toast;

public class SaveBitmap{
	//授权
	//<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/> 
	String pathString;
	
	public String getFilePath() {
		return pathString;
	}
	public void Save(Context cls,Bitmap bitmap){
		// TODO Auto-generated method stub
		 
		String filename=Environment.getExternalStorageDirectory().getPath()+"/DCIM/Gallery2/";
		File file = new File(filename);
		if (!file.exists())
			file.mkdirs(); 
		try {
		 
			
			SimpleDateFormat format=new SimpleDateFormat("yyyy-mm-dd-HH-mm-ss");
			String time=format.format(new java.util.Date());
			pathString=filename+"Gallery2_"+time+".jpg";
			FileOutputStream fos = new FileOutputStream(pathString);
			bitmap.compress(Bitmap.CompressFormat.JPEG, 90, fos);// 质量90			 
			fos.flush();
			fos.close();
			Toast.makeText(cls,"保存成功\r\n"+"保存位置为："+filename+time+".jpg", Toast.LENGTH_SHORT).show();
			 
		} catch (Exception e) {
			e.printStackTrace();
		}
	}
}
